package com.koron.bean.enums;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author jzp
 * @since 2021/9/27
 */
public enum OperationMode {
    INSERT(),
    UPDATE(),
    INSERT_UPDATE(),
    AUTO(),
    ;

    private static final Set<OperationMode> insertMode = new HashSet<>(Arrays.asList(OperationMode.INSERT, OperationMode.INSERT_UPDATE));

    private static final Set<OperationMode> updateMode = new HashSet<>(Arrays.asList(OperationMode.UPDATE, OperationMode.INSERT_UPDATE));

    public static boolean hasInsertMode(OperationMode adapterMode, OperationMode annoMode) {
        if (annoMode != OperationMode.AUTO) {
            return insertMode.contains(annoMode);
        }
        return insertMode.contains(adapterMode);
    }

    public static boolean hasUpdateMode(OperationMode adapterMode, OperationMode annoMode) {
        if (annoMode != OperationMode.AUTO) {
            return updateMode.contains(annoMode);
        }
        return updateMode.contains(adapterMode);
    }
}
